#region Namespace References

using System;
using DynConDevCorp.OpenArch.SmartData.Interfaces;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.Interfaces
{
    /// <summary>
    /// Standard Delegate for converting a specific type to a string using a provided format string.
    /// </summary>
    public delegate string FormatHandler<TData>(TData source, string format);
    
    /// <summary>
    /// Base Interface for Formatters used to translate Value to DisplayValue for ISmartFields.
    /// </summary>
    public interface ISmartDisplayFormatter : ISmartProperty
    {
        #region Public Instance Properties

        /// <summary>
        /// Gets the type of the target.
        /// </summary>
        /// <value>The type of the target.</value>
        Type TargetType { get; }

        /// <summary>
        /// Gets or sets the format string.
        /// </summary>
        /// <value>The format string.</value>
        string FormatString { get; set; }

        string Format(object value, string formatString);

        #endregion

        #region Public Instance Methods

        #endregion
    }

    /// <summary>
    /// Type Safe Interface for Formatters used to translate Value to DisplayValue for ISmartFields.
    /// </summary>
    /// <typeparam name="TData">The type of the data to be formatted.</typeparam>
    public interface ISmartDisplayFormatter<TData> : ISmartDisplayFormatter
        where TData : IComparable<TData>
    {
        #region Public Instance Properties

        /// <summary>
        /// Gets or sets the bound field.
        /// </summary>
        /// <value>The bound field.</value>
        ISmartField<TData> BoundField { get; set; }


        /// <summary>
        /// Gets or sets the current handler.
        /// </summary>
        /// <value>The current handler.</value>
        FormatHandler<TData> CurrentHandler { get; set; }

        #endregion

        #region Public Instance Methods

        /// <summary>
        /// Formats the specified data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="value">Override of Member format String. Pass NullOrEmpty to use Member.</param>
        /// <returns>The Formatted Data</returns>
        string Format(TData data, string value);

        #endregion
    }
}